package lambda;
import lambda.interF.GetArgsStu;
import lambda.model.Student;
import java.util.function.Supplier;
public class demo5 {
    public static void main(String[] args) {
        //1.无参构造方法引用
        //调用无参构造方法，返回一个Student 对象，符合Supplier(void,T)函数式接口定义
        Supplier<Student> supplier=Student::new;
        System.out.println(supplier.get());
        //等价lambda
        Supplier<Student> supplierLambda=()->new Student();
        System.out.println(supplierLambda.get());

        //2.有参构造方法引用
        //调用自定义有参构造，使用自定义的函数式接口getArgsStu(T,V)，
        //符合自定义GetArgsStu(T,V)函数式接口定义
        GetArgsStu<String,Student> getArgsStu=Student::new;
        System.out.println(getArgsStu.get("欢欢"));
        //等价lambda
        GetArgsStu<String,Student>getArgsStuLabmda=(name)->new Student(name);
        System.out.println(getArgsStuLabmda.get("哈哈"));
    }
}
